//@author A0092201X
/*********************************************************************************************************
Name: Task
Type: Class
Purpose: Serves as an object that stores all attributes of a task.
	     It supports the overloading of constructors by:
		 (1) Tabbed formatted string
		 (2) int task index and tabbed formatted string
		 (3) Task attributes - string Description, time_t Start date/time, 
		 time_t End/Deadline date/time, string Location
Pre-conditions: Assumes that the taskString recieved is tab-separated with the following attributes:
				(1) Task type code
				(2) Description
				(3) Start date/time
				(4) End/Deadline date/time
				(5) Location
Post-conditions: Private attributes should be assigned after initalisation.
				 Empty index will be stored as (int) -1, empty time as (time_t) 0, empty location as "".
				 Public methods will only allow the construction of the task, 
				 and retrieval of its attributes. 
**************************************************************************************************************/

#pragma once

#include <string>
#include <sstream>
#include <ctime>

#include "Exception.h"

//Task internal int/long declarations:
const int END_OF_STRING = -1;
const int NO_INDEX = -1;
const long NO_TIME = 0;

//Task type code constant string declarations:
const std::string CODE_TIMED = "[T]";
const std::string CODE_PARTIALTIMED = "[P]";
const std::string CODE_DEADLINE = "[D]";
const std::string CODE_FLOATING = "[F]";
const std::string CODE_INVALID = "[I]";

//Positive int chars constant string declaration:
const std::string INTS = "0123456789";

class Task {

private:
	int _index;
	std::string _code;
	std::string _description;
	time_t _startDateTime;
	time_t _endDateTime;
	std::string _location;

	void initialise(std::string);
	int getTabPosition(std::string, unsigned int);
	bool checkTaskCodeValidity(std::string);
	time_t getTimeT(std::string);
	void checkDateTimeValidity(int, int, int, int, int);

public:
	Task(std::string);
	Task(int, std::string);
	Task(std::string, time_t, time_t, std::string); 
	~Task(void);
	int getIndex(void);
	std::string getCode(void);
	std::string getDescription(void);
	time_t getStartDateTime(void);
	time_t getEndDateTime(void);
	std::string getLocation(void);
	std::string prepareLine(void);
	void setInvalid();
};

